<?php require_once('../Connections/locale.php'); ?>
<?php
mysql_select_db($database_locale, $locale);
$query_riviste = "SELECT * FROM riviste";
$riviste = mysql_query($query_riviste, $locale) or die(mysql_error());
$row_riviste = mysql_fetch_assoc($riviste);
$totalRows_riviste = mysql_num_rows($riviste);

mysql_select_db($database_locale, $locale);
$query_tipologie = "SELECT * FROM tipologie";
$tipologie = mysql_query($query_tipologie, $locale) or die(mysql_error());
$row_tipologie = mysql_fetch_assoc($tipologie);
$totalRows_tipologie = mysql_num_rows($tipologie);

mysql_select_db($database_locale, $locale);
$query_fatture = "SELECT * FROM stati_fattura";
$fatture = mysql_query($query_fatture, $locale) or die(mysql_error());
$row_fatture = mysql_fetch_assoc($fatture);
$totalRows_fatture = mysql_num_rows($fatture);

mysql_select_db($database_locale, $locale);
$query_commissionarie = "SELECT * FROM commissionarie";
$commissionarie = mysql_query($query_commissionarie, $locale) or die(mysql_error());
$row_commissionarie = mysql_fetch_assoc($commissionarie);
$totalRows_commissionarie = mysql_num_rows($commissionarie);

mysql_select_db($database_locale, $locale);
$query_categorie = "SELECT * FROM categorie";
$categorie = mysql_query($query_categorie, $locale) or die(mysql_error());
$row_categorie = mysql_fetch_assoc($categorie);
$totalRows_categorie = mysql_num_rows($categorie);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Untitled Document</title>
<link href="../style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../epoch_styles.css" />
<script type="text/javascript" src="../jscripts/epoch_classes.js"></script>
</head>

<body>
<form id="form1" name="form1" method="post" action="risultati_ricerca.php">
  <table width="70%" border="0">
    <tr>
      <th width="30%" scope="row">Rivista:</th>
      <td><label>
        <select name="id_rivista" id="id_rivista">
          <option value="-1">Nessuna</option>
          <?php
do {  
?>
          <option value="<?php echo $row_riviste['id_rivista']?>"><?php echo $row_riviste['descrizione']?></option>
          <?php
} while ($row_riviste = mysql_fetch_assoc($riviste));
  $rows = mysql_num_rows($riviste);
  if($rows > 0) {
      mysql_data_seek($riviste, 0);
	  $row_riviste = mysql_fetch_assoc($riviste);
  }
?>
        </select>
      </label></td>
    </tr>
    <tr>
      <th scope="row">Tipologia:</th>
      <td><label>
        <select name="id_tipologia" id="id_tipologia">
          <option value="-1">Nessuna</option>
          <?php
do {  
?>
          <option value="<?php echo $row_tipologie['id_tipologia']?>"><?php echo $row_tipologie['descrizione_tipologia']?></option>
          <?php
} while ($row_tipologie = mysql_fetch_assoc($tipologie));
  $rows = mysql_num_rows($tipologie);
  if($rows > 0) {
      mysql_data_seek($tipologie, 0);
	  $row_tipologie = mysql_fetch_assoc($tipologie);
  }
?>
        </select>
      </label></td>
    </tr>
    <tr>
      <th scope="row">Categoria:</th>
      <td><label>
        <select name="id_categoria" id="id_categoria">
          <option value="-1">Nessuna</option>
          <?php
do {  
?>
          <option value="<?php echo $row_categorie['id_categoria']?>"><?php echo $row_categorie['descrizione_categoria']?></option>
          <?php
} while ($row_categorie = mysql_fetch_assoc($categorie));
  $rows = mysql_num_rows($categorie);
  if($rows > 0) {
      mysql_data_seek($categorie, 0);
	  $row_categorie = mysql_fetch_assoc($categorie);
  }
?>
        </select>
      </label></td>
    </tr>
    <tr>
      <th scope="row">Stato Fattura: </th>
      <td><label>
        <select name="id_stato_fattura" id="id_stato_fattura">
          <option value="-1">Nessuno</option>
          <?php
do {  
?>
          <option value="<?php echo $row_fatture['id_stato_fattura']?>"><?php echo $row_fatture['descrizione']?></option>
          <?php
} while ($row_fatture = mysql_fetch_assoc($fatture));
  $rows = mysql_num_rows($fatture);
  if($rows > 0) {
      mysql_data_seek($fatture, 0);
	  $row_fatture = mysql_fetch_assoc($fatture);
  }
?>
        </select>
      </label></td>
    </tr>
    <tr>
      <th scope="row">Stato Pagamento: </th>
      <td><select name="pagamento" id="pagamento">
        <option value="-1">Nessuno</option>
        <option value="0">Non Pagato</option>
        <option value="1">Pagato</option>
      </select></td>
    </tr>
    <tr>
      <th scope="row">Commissionaria:</th>
      <td><label>
        <select name="id_commissionaria" id="id_commissionaria">
          <option value="-1">Nessuna</option>
<?php
do {  
?>
          <option value="<?php echo $row_commissionarie['id_commissionaria']?>"><?php echo $row_commissionarie['nome']?></option>
          <?php
} while ($row_commissionarie = mysql_fetch_assoc($commissionarie));
  $rows = mysql_num_rows($commissionarie);
  if($rows > 0) {
      mysql_data_seek($commissionarie, 0);
	  $row_commissionarie = mysql_fetch_assoc($commissionarie);
  }
?>
        </select>
      </label></td>
    </tr>
    <tr>
      <th scope="row"> Scadenza:</th>
      <td> da 

        <input name="scadenza_da" type="text" id="scadenza_da" size="11" />
		
      a 
      <input name="scadenza_a" type="text" id="scadenza_a" size="11" />
	  		  <script language="JavaScript" type="text/javascript">
	var dp_cal1  = new Epoch('epoch_popup1','popup',document.getElementById('scadenza_da'));
		var dp_cal2  = new Epoch('epoch_popup2','popup',document.getElementById('scadenza_a'));
	
	</script>	  
	  </td>
    </tr>
  </table>
  <p>
    <label>
    <input type="submit" name="Submit" value="Cerca" />
    </label>
  </p>
</form>
</body>
</html>
<?php
mysql_free_result($riviste);

mysql_free_result($tipologie);

mysql_free_result($fatture);

mysql_free_result($commissionarie);

mysql_free_result($categorie);
?>
